<!DOCTYPE html>
<html>
  <head>
    <title></title>
    <link rel='stylesheet' href='/stylesheets/style.css' />
    <script type="text/javascript" src="socket.io/socket.io.js">
    </script>

  </head>
  <body>
    <%if(!User){%>
    <form action="/reg" method="post">
      <input type="text" name="userName">
      <input type="password" name="passWord">
      <input type="password" name="confirm">
      <input type="submit" value="注册">
    </form>
    <form action="login" method="post">
    <input type="text" name="userName">
    <input type="password" name="passWord">
    <input type="submit" value="登录">
    </form>
    <%}%>
    <div class="list">
      <%Message.forEach(item=>{%>
        <p><%=item.User%>:<%=item.Message%> | "发表于"<%=item.time%></p>
      <%});%>
    </div>
  <input type="text" onchange="display(event)">
  <script type="text/javascript">
  var socket=io.connect();
  var list=document.querySelector(".list");
  function display(event){
    socket.emit("say",event.target.value,function (res){
    });
  socket.on("return",data=>{
    var p=document.createElement("p");
    p.innerText=data;
    list.appendChild(p);
  })};
  </script>
  </body>
</html>
